package com.itheima01.day06test;

/**
 * @author 刘全
 * @date 2021/7/6
 */
// 获取水仙花数的个数，并返回。
public class MethodTest02 {
    public static void main(String[] args) {
        System.out.println("水仙花数的个数为:" + num());
    }

    public static int num() {
        int a = 0, b = 0, c = 0;
        int count = 0;
        System.out.println("水仙花数为:");
        for (int i = 100; i < 1000; i++) {
            a = i / 100;
            b = i / 10 % 10;
            c = i % 10;
            if (a * a * a + b * b * b + c * c * c == i) {
                System.out.print(i + " ");
                count++;
            }
        }
        System.out.println();
        return count;
    }
}
